/*
 * Class Gui
 *
 * Version 1.0
 *
 * Wednesday September 23, 2009
 *
 * Created by Hunter
 */

package net.com.codeusa;

import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class Gui extends JFrame {

    static private JTextField textkick;
    static private JTextField update;
    private JLabel textt;
    private JButton button1;
    private JLabel text;
    private JButton button2;
    private JPanel panel;

	public Gui() {
		super("Control Panel"); // The title bar
		setLayout(new FlowLayout()); // This is the layout of the Gui
		JPanel panel = new JPanel(new GridBagLayout());

		textt = new JLabel("Enter a name to kick.");		
		text = new JLabel("Time to update:");
		update = new JTextField("30");
		textkick = new JTextField("Enter a username to kick");
		textkick.setToolTipText("Type in the username to kick here.");

		button1 = new JButton("KICK"); //button on the gui
		button2 = new JButton("Update");
		button1.setToolTipText("Click to kick."); //Hover text
		
		add(panel);

		GridBagConstraints c = new GridBagConstraints();
		
		c.gridx = 0; //Position of textt
		c.gridy = 0; // All of these are the X, Y position of the selected item
		panel.add(textt, c);
		c.gridx = 50; //Position of textt
		c.gridy = 25; // All of these are the X, Y position of the selected item
		panel.add(text, c);//For example, here the selected item is "textt"
		c.gridx = 0;
		c.gridy = 50;
		panel.add(textkick, c);	
		c.gridx = 0;
		c.gridy = 100;
		panel.add(button1, c);
		c.gridx = 25; //Position of textt
		c.gridy = 75; // All of these are the X, Y position of the selected item
		panel.add(update, c);
		c.gridx = 50;
		c.gridy = 100;
		panel.add(button2, c);
		button1.addActionListener(new Action()); //Adds an ActionListener to button1
		button2.addActionListener(new Action()); //Adds an ActionListener to button2
	}
	
	static class Action implements ActionListener {
	   public void actionPerformed (ActionEvent e) {
     String kickwho = textkick.getText(); // Gets the text for textkick
     String ttu = update.getText(); // Gets the text for textkick
	//Here, you still need to add where it kicks "kickwho" kick who is what
 	//Is in the textField

			System.out.println("Kicked "+kickwho+" from the server."); //What happens when button1 is clicked
			System.out.println("Updating in "+ttu+" seconds.");
		} 
 
	}
}